
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>使用Rasterio读取栅格数据 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="使用Rasterio创建栅格数据.html" />
    
    
    <link rel="prev" href="README.md" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../Python基础/">
            
                <a href="../../Python基础/">
            
                    
                    Python基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../Python基础/Python环境搭建及基本数据类型.html">
            
                <a href="../../Python基础/Python环境搭建及基本数据类型.html">
            
                    
                    Python环境搭建及基本数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../Python基础/运算符及字符串.html">
            
                <a href="../../Python基础/运算符及字符串.html">
            
                    
                    运算符及字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../Python基础/序列与字典.html">
            
                <a href="../../Python基础/序列与字典.html">
            
                    
                    序列与字典
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../../Python基础/流程控制语句.html">
            
                <a href="../../Python基础/流程控制语句.html">
            
                    
                    流程控制语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../../Python基础/函数.html">
            
                <a href="../../Python基础/函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../../Python基础/面向对象编程初识.html">
            
                <a href="../../Python基础/面向对象编程初识.html">
            
                    
                    面向对象编程初识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../../Python基础/面向对象编程高级.html">
            
                <a href="../../Python基础/面向对象编程高级.html">
            
                    
                    面向对象编程高级
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../../Python基础/Python科学计算.html">
            
                <a href="../../Python基础/Python科学计算.html">
            
                    
                    Python科学计算
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../../Python基础/空间数据处理环境搭建.html">
            
                <a href="../../Python基础/空间数据处理环境搭建.html">
            
                    
                    空间数据处理环境搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../空间数据基础/">
            
                <a href="../../空间数据基础/">
            
                    
                    空间数据基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../空间数据基础/空间参考系统.html">
            
                <a href="../../空间数据基础/空间参考系统.html">
            
                    
                    空间参考系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../空间数据基础/地图投影.html">
            
                <a href="../../空间数据基础/地图投影.html">
            
                    
                    地图投影
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../空间数据基础/空间数据.html">
            
                <a href="../../空间数据基础/空间数据.html">
            
                    
                    空间数据
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../">
            
                <a href="../">
            
                    
                    GDAL空间数据处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../GDAL简介.html">
            
                <a href="../GDAL简介.html">
            
                    
                    GDAL简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../GDAL数据基本操作.html">
            
                <a href="../GDAL数据基本操作.html">
            
                    
                    GDAL数据基本操作
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.2.1" data-path="../GDAL数据基本操作/打开栅格数据的正确方式.html">
            
                <a href="../GDAL数据基本操作/打开栅格数据的正确方式.html">
            
                    
                    打开栅格数据的正确方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.2" data-path="../GDAL数据基本操作/栅格数据格式转换.html">
            
                <a href="../GDAL数据基本操作/栅格数据格式转换.html">
            
                    
                    栅格数据格式转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.3" data-path="../GDAL数据基本操作/栅格数据创建与保存.html">
            
                <a href="../GDAL数据基本操作/栅格数据创建与保存.html">
            
                    
                    栅格数据创建与保存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.4" data-path="../GDAL数据基本操作/读取HDF或者NetCDF格式的栅格数据.html">
            
                <a href="../GDAL数据基本操作/读取HDF或者NetCDF格式的栅格数据.html">
            
                    
                    读取HDF或者NetCDF格式的栅格数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.5" data-path="../GDAL数据基本操作/栅格数据投影转换.html">
            
                <a href="../GDAL数据基本操作/栅格数据投影转换.html">
            
                    
                    栅格数据投影转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.6" data-path="../GDAL数据基本操作/栅格数据裁剪.html">
            
                <a href="../GDAL数据基本操作/栅格数据裁剪.html">
            
                    
                    栅格数据裁剪
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.7" data-path="../GDAL数据基本操作/打开Shapefile文件的正确方式.html">
            
                <a href="../GDAL数据基本操作/打开Shapefile文件的正确方式.html">
            
                    
                    打开Shapefile文件的正确方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.8" data-path="../GDAL数据基本操作/创建Shapefile文件并写入数据.html">
            
                <a href="../GDAL数据基本操作/创建Shapefile文件并写入数据.html">
            
                    
                    创建Shapefile文件并写入数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.9" data-path="../GDAL数据基本操作/矢量数据投影转换.html">
            
                <a href="../GDAL数据基本操作/矢量数据投影转换.html">
            
                    
                    矢量数据投影转换
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Fiona矢量数据处理/REDAME.md">
            
                <span>
            
                    
                    Fiona矢量数据处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.3.1" data-path="../Fiona矢量数据处理/Fiona简介及Shapefile数据读取.html">
            
                <a href="../Fiona矢量数据处理/Fiona简介及Shapefile数据读取.html">
            
                    
                    Fiona简介及Shapefile数据读取
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3.2" data-path="../Fiona矢量数据处理/使用Fiona创建Shapefile矢量数据.html">
            
                <a href="../Fiona矢量数据处理/使用Fiona创建Shapefile矢量数据.html">
            
                    
                    使用Fiona创建Shapefile矢量数据
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="README.md">
            
                <span>
            
                    
                    Rasterio栅格数据处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.4.1" data-path="使用Rasterio读取栅格数据.html">
            
                <a href="使用Rasterio读取栅格数据.html">
            
                    
                    使用Rasterio读取栅格数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4.2" data-path="使用Rasterio创建栅格数据.html">
            
                <a href="使用Rasterio创建栅格数据.html">
            
                    
                    使用Rasterio创建栅格数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4.3" data-path="使用Rasterio做投影变换.html">
            
                <a href="使用Rasterio做投影变换.html">
            
                    
                    使用Rasterio做投影变换
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >使用Rasterio读取栅格数据</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4F7F;&#x7528;rasterio&#x8BFB;&#x53D6;&#x6805;&#x683C;&#x6570;&#x636E;">&#x4F7F;&#x7528;Rasterio&#x8BFB;&#x53D6;&#x6805;&#x683C;&#x6570;&#x636E;</h1>
<p>&#x4F5C;&#x8005;&#xFF1A;&#x963F;&#x632F; &#x90AE;&#x7BB1;&#xFF1A;tanzhenyugis@163.com </p>
<p>&#x535A;&#x5BA2;&#xFF1A;<a href="https://blog.csdn.net/theonegis/article/details/80089375" target="_blank">https://blog.csdn.net/theonegis/article/details/80089375</a> </p>
<p>&#x4FEE;&#x6539;&#x65F6;&#x95F4;&#xFF1A;2018-06-06 </p>
<p>&#x58F0;&#x660E;&#xFF1A;&#x672C;&#x6587;&#x4E3A;&#x535A;&#x4E3B;&#x539F;&#x521B;&#x6587;&#x7AE0;&#xFF0C;&#x8F6C;&#x8F7D;&#x8BF7;&#x6CE8;&#x660E;&#x539F;&#x6587;&#x51FA;&#x5904;</p>
<hr>
<h2 id="rasterio&#x7B80;&#x4ECB;">Rasterio&#x7B80;&#x4ECB;</h2>
<p>&#x6709;&#x6CA1;&#x6709;&#x89C9;&#x5F97;&#x7528;GDAL&#x7684;Python&#x7ED1;&#x5B9A;&#x4E66;&#x5199;&#x7684;&#x4EE3;&#x7801;&#x5F88;&#x4E0D;Pythonic&#xFF0C;&#x5F3A;&#x8FEB;&#x75C7;&#x7684;&#x4F60;&#x53EF;&#x80FD;&#x6709;&#x4E9B;&#x5FCD;&#x53D7;&#x4E0D;&#x4E86;&#x3002;&#x4E0D;&#x8FC7;&#xFF0C;&#x6CA1;&#x5173;&#x7CFB;&#xFF0C;MapBox&#x65D7;&#x4E0B;&#x7684;&#x5F00;&#x6E90;&#x5E93;Rasterio&#x5E2E;&#x6211;&#x4EEC;&#x89E3;&#x51B3;&#x4E86;&#x8FD9;&#x4E2A;&#x75DB;&#x70B9;&#x3002;</p>
<p>Rasterio&#x662F;&#x57FA;&#x4E8E;GDAL&#x5E93;&#x4E8C;&#x6B21;&#x5C01;&#x88C5;&#x7684;&#x66F4;&#x52A0;&#x7B26;&#x5408;Python&#x98CE;&#x683C;&#x7684;&#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x7A7A;&#x95F4;&#x6805;&#x683C;&#x6570;&#x636E;&#x5904;&#x7406;&#x7684;Python&#x5E93;&#x3002;</p>
<p>Rasterio&#x4E2D;&#x6805;&#x683C;&#x6570;&#x636E;&#x6A21;&#x578B;&#x57FA;&#x672C;&#x548C;GDAL&#x7C7B;&#x4F3C;&#xFF0C;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF1A;</p>
<p>&#x5728;Rasterio 1.0&#x4EE5;&#x540E;&#xFF0C;&#x5BF9;&#x4E8E;GeoTransform&#x7684;&#x8868;&#x793A;&#x5F03;&#x7528;&#x4E86;GDAL&#x98CE;&#x683C;&#x7684;&#x653E;&#x5C04;&#x53D8;&#x6362;&#xFF0C;&#x800C;&#x4F7F;&#x7528;&#x4E86;Python&#x653E;&#x5C04;&#x53D8;&#x6362;&#x7684;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;<a href="https://github.com/sgillies/affine" target="_blank">affine</a>&#x5E93;&#x7684;&#x98CE;&#x683C;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x653E;&#x5C04;&#x53D8;&#x6362;</p>
<pre><code>affine.Affine(a, b, c,
              d, e, f)
</code></pre><p>GDAL&#x4E2D;&#x5BF9;&#x5E94;&#x7684;&#x53C2;&#x6570;&#x987A;&#x5E8F;&#x662F;&#xFF1A;<code>(c, a, b, f, d, e)</code></p>
<p>&#x91C7;&#x7528;&#x65B0;&#x7684;&#x653E;&#x5C04;&#x53D8;&#x6362;&#x6A21;&#x578B;&#x7684;&#x597D;&#x5904;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x9700;&#x8981;&#x8BA1;&#x7B97;&#x67D0;&#x4E2A;&#x884C;&#x5217;&#x53F7;&#x7684;&#x5730;&#x7406;&#x5750;&#x6807;&#xFF0C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x884C;&#x5217;&#x53F7;&#x8DDF;&#x7ED9;&#x653E;&#x5C04;&#x53D8;&#x6362;&#x5BF9;&#x8C61;&#x76F8;&#x4E58;&#x5373;&#x53EF;&#xFF0C;&#x5B8C;&#x5168;&#x7B26;&#x5408;&#x6570;&#x5B66;&#x4E0A;&#x77E9;&#x9635;&#x4E58;&#x6CD5;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x66F4;&#x52A0;&#x76F4;&#x89C2;&#x548C;&#x65B9;&#x4FBF;&#x3002;</p>
<h1 id="&#x6805;&#x683C;&#x6570;&#x636E;&#x8BFB;&#x53D6;&#x4EE3;&#x7801;&#x793A;&#x4F8B;">&#x6805;&#x683C;&#x6570;&#x636E;&#x8BFB;&#x53D6;&#x4EE3;&#x7801;&#x793A;&#x4F8B;</h1>
<p>&#x4E0B;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x7A0B;&#x5E8F;&#x4E2D;&#x6F14;&#x793A;&#x4E86;&#x5982;&#x4F55;&#x8BFB;&#x53D6;&#x4E00;&#x4E2A;GeoTIFF&#x6587;&#x4EF6;&#x5E76;&#x83B7;&#x53D6;&#x76F8;&#x5173;&#x4FE1;&#x606F;&#xFF0C;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF1A;</p>
<ol>
<li>rasterio&#x4F7F;&#x7528;<code>rasterio.open()</code>&#x51FD;&#x6570;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x6805;&#x683C;&#x6587;&#x4EF6;</li>
<li>rasterio&#x4F7F;&#x7528;<code>read()</code>&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x5C06;&#x6570;&#x636E;&#x96C6;&#x8F6C;&#x4E3A;<code>numpy.ndarray</code>&#xFF0C;&#x8BE5;&#x51FD;&#x6570;&#x5982;&#x679C;&#x4E0D;&#x5E26;&#x53C2;&#x6570;&#xFF0C;&#x5C06;&#x628A;&#x6570;&#x636E;&#x7684;&#x6240;&#x6709;&#x6CE2;&#x6BB5;&#x505A;&#x8F6C;&#x6362;&#xFF08;&#x7B2C;&#x4E00;&#x7EF4;&#x662F;&#x6CE2;&#x6BB5;&#x6570;&#xFF09;&#xFF0C;&#x5982;&#x679C;&#x6307;&#x5B9A;&#x6CE2;&#x6BB5;&#xFF0C;&#x5219;&#x53EA;&#x53D6;&#x5F97;&#x6307;&#x5B9A;&#x6CE2;&#x6BB5;&#x5BF9;&#x5E94;&#x7684;&#x6570;&#x636E;&#xFF08;&#x6CE2;&#x6BB5;&#x7D22;&#x5F15;&#x4ECE;1&#x5F00;&#x59CB;&#xFF09;</li>
<li>&#x6570;&#x636E;&#x7684;&#x5F88;&#x591A;&#x5143;&#x4FE1;&#x606F;&#x90FD;&#x662F;&#x4EE5;&#x6570;&#x636E;&#x96C6;&#x7684;&#x5C5E;&#x6027;&#x8FDB;&#x884C;&#x8868;&#x793A;&#x7684;</li>
</ol>
<pre><code class="lang-Python"><span class="hljs-keyword">import</span> rasterio

<span class="hljs-keyword">with</span> rasterio.open(<span class="hljs-string">&apos;example.tif&apos;</span>) <span class="hljs-keyword">as</span> ds:
    print(<span class="hljs-string">&apos;&#x8BE5;&#x6805;&#x683C;&#x6570;&#x636E;&#x7684;&#x57FA;&#x672C;&#x6570;&#x636E;&#x96C6;&#x4FE1;&#x606F;&#xFF08;&#x8FD9;&#x4E9B;&#x4FE1;&#x606F;&#x90FD;&#x662F;&#x4EE5;&#x6570;&#x636E;&#x96C6;&#x5C5E;&#x6027;&#x7684;&#x5F62;&#x5F0F;&#x8868;&#x793A;&#x7684;&#xFF09;&#xFF1A;&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x6570;&#x636E;&#x683C;&#x5F0F;&#xFF1A;{ds.driver}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x6CE2;&#x6BB5;&#x6570;&#x76EE;&#xFF1A;{ds.count}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x5F71;&#x50CF;&#x5BBD;&#x5EA6;&#xFF1A;{ds.width}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x5F71;&#x50CF;&#x9AD8;&#x5EA6;&#xFF1A;{ds.height}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x5730;&#x7406;&#x8303;&#x56F4;&#xFF1A;{ds.bounds}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x53CD;&#x5C04;&#x53D8;&#x6362;&#x53C2;&#x6570;&#xFF08;&#x516D;&#x53C2;&#x6570;&#x6A21;&#x578B;&#xFF09;&#xFF1A;\n {ds.transform}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x6295;&#x5F71;&#x5B9A;&#x4E49;&#xFF1A;{ds.crs}&apos;</span>)
    <span class="hljs-comment"># &#x83B7;&#x53D6;&#x7B2C;&#x4E00;&#x4E2A;&#x6CE2;&#x6BB5;&#x6570;&#x636E;&#xFF0C;&#x8DDF;GDAL&#x4E00;&#x6837;&#x7D22;&#x5F15;&#x4ECE;1&#x5F00;&#x59CB;</span>
    <span class="hljs-comment"># &#x76F4;&#x63A5;&#x83B7;&#x5F97;numpy.ndarray&#x7C7B;&#x578B;&#x7684;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x8868;&#x793A;&#xFF0C;&#x5982;&#x679C;read()&#x51FD;&#x6570;&#x4E0D;&#x52A0;&#x53C2;&#x6570;&#xFF0C;&#x5219;&#x5F97;&#x5230;&#x6240;&#x6709;&#x6CE2;&#x6BB5;&#xFF08;&#x7B2C;&#x4E00;&#x4E2A;&#x7EF4;&#x5EA6;&#x662F;&#x6CE2;&#x6BB5;&#xFF09;</span>
    band1 = ds.read(<span class="hljs-number">1</span>)
    print(f<span class="hljs-string">&apos;&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#x7684;&#x6700;&#x5927;&#x503C;&#xFF1A;{band1.max()}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#x7684;&#x6700;&#x5C0F;&#x503C;&#xFF1A;{band1.min()}&apos;</span>)
    print(f<span class="hljs-string">&apos;&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#x7684;&#x5E73;&#x5747;&#x503C;&#xFF1A;{band1.mean()}&apos;</span>)
    <span class="hljs-comment"># &#x6839;&#x636E;&#x5730;&#x7406;&#x5750;&#x6807;&#x5F97;&#x5230;&#x884C;&#x5217;&#x53F7;</span>
    x, y = (ds.bounds.left + <span class="hljs-number">300</span>, ds.bounds.top - <span class="hljs-number">300</span>)  <span class="hljs-comment"># &#x8DDD;&#x79BB;&#x5DE6;&#x4E0A;&#x89D2;&#x4E1C;300&#x7C73;&#xFF0C;&#x5357;300&#x7C73;&#x7684;&#x6295;&#x5F71;&#x5750;&#x6807;</span>
    row, col = ds.index(x, y)  <span class="hljs-comment"># &#x5BF9;&#x5E94;&#x7684;&#x884C;&#x5217;&#x53F7;</span>
    print(f<span class="hljs-string">&apos;(&#x6295;&#x5F71;&#x5750;&#x6807;{x}, {y})&#x5BF9;&#x5E94;&#x7684;&#x884C;&#x5217;&#x53F7;&#x662F;({row}, {col})&apos;</span>)
    <span class="hljs-comment"># &#x6839;&#x636E;&#x884C;&#x5217;&#x53F7;&#x5F97;&#x5230;&#x5730;&#x7406;&#x5750;&#x6807;</span>
    x, y = ds.xy(row, col)  <span class="hljs-comment"># &#x4E2D;&#x5FC3;&#x70B9;&#x7684;&#x5750;&#x6807;</span>
    print(f<span class="hljs-string">&apos;&#x884C;&#x5217;&#x53F7;({row}, {col})&#x5BF9;&#x5E94;&#x7684;&#x4E2D;&#x5FC3;&#x6295;&#x5F71;&#x5750;&#x6807;&#x662F;({x}, {y})&apos;</span>)
    <span class="hljs-comment"># &#x90A3;&#x4E48;&#x5982;&#x4F55;&#x5F97;&#x5230;&#x5BF9;&#x5E94;&#x70B9;&#x5DE6;&#x4E0A;&#x89D2;&#x7684;&#x4FE1;&#x606F;</span>
    x, y = (row, col) * ds.transform
    print(f<span class="hljs-string">&apos;&#x884C;&#x5217;&#x53F7;({row}, {col})&#x5BF9;&#x5E94;&#x7684;&#x5DE6;&#x4E0A;&#x89D2;&#x6295;&#x5F71;&#x5750;&#x6807;&#x662F;({x}, {y})&apos;</span>)
</code></pre>
<p>&#x8F93;&#x51FA;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>&#x8BE5;&#x6805;&#x683C;&#x6570;&#x636E;&#x7684;&#x57FA;&#x672C;&#x6570;&#x636E;&#x96C6;&#x4FE1;&#x606F;&#xFF08;&#x8FD9;&#x4E9B;&#x4FE1;&#x606F;&#x90FD;&#x662F;&#x4EE5;&#x6570;&#x636E;&#x96C6;&#x5C5E;&#x6027;&#x7684;&#x5F62;&#x5F0F;&#x8868;&#x793A;&#x7684;&#xFF09;&#xFF1A;
&#x6570;&#x636E;&#x683C;&#x5F0F;&#xFF1A;GTiff
&#x6CE2;&#x6BB5;&#x6570;&#x76EE;&#xFF1A;3
&#x5F71;&#x50CF;&#x5BBD;&#x5EA6;&#xFF1A;4800
&#x5F71;&#x50CF;&#x9AD8;&#x5EA6;&#xFF1A;4800
&#x5730;&#x7406;&#x8303;&#x56F4;&#xFF1A;BoundingBox(left=725385.0, bottom=2648415.0, right=869385.0, top=2792415.0)
&#x53CD;&#x5C04;&#x53D8;&#x6362;&#x53C2;&#x6570;&#xFF08;&#x516D;&#x53C2;&#x6570;&#x6A21;&#x578B;&#xFF09;&#xFF1A;
 | 30.00, 0.00, 725385.00|
| 0.00,-30.00, 2792415.00|
| 0.00, 0.00, 1.00|
&#x6295;&#x5F71;&#x5B9A;&#x4E49;&#xFF1A;CRS({&apos;init&apos;: &apos;epsg:32649&apos;})
&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#x7684;&#x6700;&#x5927;&#x503C;&#xFF1A;5459
&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#x7684;&#x6700;&#x5C0F;&#x503C;&#xFF1A;-313
&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#x7684;&#x5E73;&#x5747;&#x503C;&#xFF1A;489.80300625
(&#x6295;&#x5F71;&#x5750;&#x6807;725685.0, 2792115.0)&#x5BF9;&#x5E94;&#x7684;&#x884C;&#x5217;&#x53F7;&#x662F;(10, 10)
&#x884C;&#x5217;&#x53F7;(10, 10)&#x5BF9;&#x5E94;&#x7684;&#x4E2D;&#x5FC3;&#x6295;&#x5F71;&#x5750;&#x6807;&#x662F;(725700.0, 2792100.0)
&#x884C;&#x5217;&#x53F7;(10, 10)&#x5BF9;&#x5E94;&#x7684;&#x5DE6;&#x4E0A;&#x89D2;&#x6295;&#x5F71;&#x5750;&#x6807;&#x662F;(725685.0, 2792115.0)
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="README.md" class="navigation navigation-prev " aria-label="Previous page: Rasterio栅格数据处理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="使用Rasterio创建栅格数据.html" class="navigation navigation-next " aria-label="Next page: 使用Rasterio创建栅格数据">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"使用Rasterio读取栅格数据","level":"1.4.4.1","depth":3,"next":{"title":"使用Rasterio创建栅格数据","level":"1.4.4.2","depth":3,"path":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio创建栅格数据.md","ref":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio创建栅格数据.md","articles":[]},"previous":{"title":"Rasterio栅格数据处理","level":"1.4.4","depth":2,"path":"GDAL空间数据处理/Rasterio栅格数据处理/README.md","ref":"GDAL空间数据处理/Rasterio栅格数据处理/README.md","articles":[{"title":"使用Rasterio读取栅格数据","level":"1.4.4.1","depth":3,"path":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio读取栅格数据.md","ref":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio读取栅格数据.md","articles":[]},{"title":"使用Rasterio创建栅格数据","level":"1.4.4.2","depth":3,"path":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio创建栅格数据.md","ref":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio创建栅格数据.md","articles":[]},{"title":"使用Rasterio做投影变换","level":"1.4.4.3","depth":3,"path":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio做投影变换.md","ref":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio做投影变换.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"GDAL空间数据处理/Rasterio栅格数据处理/使用Rasterio读取栅格数据.md","mtime":"2019-03-22T18:52:30.715Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-03-22T20:04:12.549Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

